package homework;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HomeWork3 {
    public static void main(String[] args) {
        HomeWork3 homeWork3 = new HomeWork3();
        homeWork3.listToMap();
        homeWork3.mapToList();
    }
    public void listToMap( ){
        List<Student> list = new ArrayList<>();
        Student student1 = new Student(1,"张飞",16,"男");
        Student student2 = new Student(2,"关羽",18,"男");
        Student student3 = new Student(3,"刘备",19,"男");
        list.add(student1);
        list.add(student2);
        list.add(student3);
        Map<Integer,Student> map = new HashMap<>();
        for (Student stu:list){
            System.out.println(stu);
            map.put(stu.getId(),stu);
        }
        System.out.println(map);
    }
    public void mapToList( ){
        Map<Integer,Student> map = new HashMap<>();
        Student student1 = new Student(1,"张飞",16,"男");
        Student student2 = new Student(2,"关羽",18,"男");
        Student student3 = new Student(3,"刘备",19,"男");
        map.put(student1.getId(),student1);
        map.put(student2.getId(),student2);
        map.put(student3.getId(),student3);
        System.out.println(map);
        List<StudentEntry> list = new ArrayList<>();
    }
}
